package com.tinckay.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import com.tinckay.entity.po.StorehouseMeasureData;
import com.tinckay.service.StorehouseMeasureDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.baomidou.mybatisplus.extension.api.ApiController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * <p>
 * 仓体前端测距信息 前端控制器
 * </p>
 *
 * @author Jean
 * @since 2018-11-13
 */
@Api(tags = "仓体前端测距信息")
@RestController
@RequestMapping("/storehouseMeasureData")
public class StorehouseMeasureDataController extends ApiController {

    @Autowired
    private StorehouseMeasureDataService storehouseMeasureDataService;

    @GetMapping("/list")
    @ApiOperation("查询仓体前端测距信息列表")
    //@RequiresPermissions("storehouseMeasureData:list")
    public R list(@RequestParam("storeCode") String storeCode,
                  @RequestParam(required = false) String startTime,
                  @RequestParam(required = false) String endTime) {

        LambdaQueryWrapper<StorehouseMeasureData> wrapper = new QueryWrapper<StorehouseMeasureData>().
                lambda()
                .eq(StorehouseMeasureData::getStoreCode, storeCode)
                .ge(StrUtil.isNotBlank(startTime), StorehouseMeasureData::getDataTime, startTime)
                .le(StrUtil.isNotBlank(endTime), StorehouseMeasureData::getDataTime, endTime)
                .orderByAsc(StorehouseMeasureData::getDataTime);

        List<StorehouseMeasureData> result = storehouseMeasureDataService.list(wrapper);
        return success(result);
    }

    @ApiIgnore
    @GetMapping("/count")
    @ApiOperation("查询仓体前端测距统计信息")
    //@RequiresPermissions("storehouseMeasureData:count")
    public R count(@RequestParam("storeCode") String storeCode) {
        //Map<String, Object> result = storehouseMeasureDataService.count(storeCode);
        //return success(result);
        return success(null);
    }

}

